﻿paginateSupport = 
  hasNextPage : -> 
    return @entryList?.links.next != undefined
    false

  hasPrevPage : -> 
    return @entryList?.links.prev != undefined
    false
  
  getNextPage : ->
    if @hasNextPage() then return Cofe.EntryList.fromUrl(@entryList.links.next.url)
    return undefined

  getPrevPage : ->
    if @hasPrevPage() then return Cofe.EntryList.fromUrl(@entryList.links.prev.url)
    return undefined

  addNextPage : ->
    nextPage = @getNextPage()
    @refreshMode = "append"
    if nextPage isnt undefined then @changeEntryList(nextPage)
   
  goNextPage : ->
    nextPage = @getNextPage()
    @refreshMode = "replace"
    if nextPage isnt undefined then @changeEntryList(nextPage)

  goPrevPage : ->
    prevPage = @getPrevPage()
    @refreshMode = "replace"
    if prevPage isnt undefined then @changeEntryList(prevPage)

  prevClick: ->        
    @elePrevPage.addClass("disable")
    @goPrevPage()    

  nextClick: ->    
    @goNextPage()    

  displayMoreClick: ->
    @addNextPage()


Cofe.paginateSupport = paginateSupport